// import L from "leaflet";
// import "leaflet/dist/leaflet.css";
import "leaflet.chinesetmsproviders";


export function loadMap(url) {
  return L.tileLayer.chinaProvider(url, {
    maxZoom: 18,
    minZoom: 5,
    zoom: 12,
  });
}

export function baseMap(name) {
  var baseLayers = {
    高德地图: "GaoDe.Normal.Map",
    高德影像: "GaoDe.Satellite.Map",
  };
  baseLayers = Object.keys(baseLayers).reduce((layers, key) => {
    layers[key] = loadMap(baseLayers[key]);
    return layers;
  }, {});
  var map = L.map(name, {
    center: [29.84, 113.36],
    zoom: 12,
    layers: [baseLayers[Object.keys(baseLayers)[0]]],
  });

  // 加载切换地图的功能（出现在页面右上角，可通过css隐藏）
  L.control.layers(baseLayers, null).addTo(map);
  return map;
}
